package cc.chengheng.spring代码测试.config;

import cc.chengheng.spring代码测试.CircularDependency.A;
import cc.chengheng.spring代码测试.CircularDependency.B;
import org.springframework.beans.factory.annotation.Configurable;
import org.springframework.beans.factory.config.ConfigurableBeanFactory;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Lazy;
import org.springframework.context.annotation.Scope;

@Configuration
public class BeanConfig {

    //region 会提示循环依赖

    /*
     * Description:
     *
     * The dependencies of some of the beans in the application context form a cycle:
     *
     * ┌─────┐
     * |  a defined in class path resource [cc/chengheng/spring代码测试/config/BeanConfig.class]
     * ↑     ↓
     * |  b defined in class path resource [cc/chengheng/spring代码测试/config/BeanConfig.class]
     * └─────┘
     */

    @Bean
    public A a(B b) {
        A a = new A();
        a.setB(b);
        return a;
    }

    @Bean
    public B b(A a) {
        B b = new B();
        b.setA(a);
        return b;
    }
    //endregion
}
